package com.topboya.officeuser.lambda;

import com.topboya.officeuser.entity.User;

import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

/**
 * @className EditLambda
 * @Author xiaxin
 * @Date 2020/8/25 15:33
 * @Version 1.0
 **/
public class EditLambda {
    public static void main(String[] args) {
        Consumer<String> consume = (x) -> System.out.println(x);
        consume.accept("哈喽，你好!");

        //函数型接口
        Function<String, User> function = (a)->{
            User user = new User();
            user.setId(a);
            return user;
        };
        System.out.println(function.apply("2"));

        //断言式接口
        Integer age = 35;
        Predicate<Integer> predicate = (i)->i>=35;
        System.out.println(predicate.test(66));

        //BiFunction<T,U,R>
        BiFunction<String,String,User> biFunction = (a,b)->{
            User user = new User();
            user.setOfficeId(a);
            user.setId(b);
            return user;
        };
        System.out.println(biFunction.apply("1001", "1111"));
    }

}
